package org.khd.base.listener;

import org.khd.base.service.IAutoScanPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener //把当前类交给spring IOC容器管理
public class InitPermissionListener implements ServletContextListener {
    @Autowired
    private IAutoScanPermissionService autoScanPermissionService;

    //容器初始化时执行
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        System.out.println("------容器初始化开始------");

        autoScanPermissionService.scan();

        System.out.println("------容器初始化结束------");
    }

    //容器销毁时执行
    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        System.out.println("------容器销毁------");
    }
}
